package com.dingding.order.core.special.dao.impl;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.daox.IBaseDaoX;
import com.dingding.common.core.base.daox.ISQLBaseDao;
import com.dingding.common.core.beans.special.UserspecialorderT;
import com.dingding.order.core.special.dao.IUserSpecialOrdertDao;
import com.dingding.order.core.special.sql.UserSpecialOrdertSQL;

/**
 * 
 * @ClassName: UserSpecialOrdertDaoImpl 
 * @Description: 专车订单(待完成、待取消)DAO实现类
 * @author YHQ
 * @date 2016年12月2日 下午5:08:36
 * @since V2.5.7
 * 
 */
@Component("userSpecialOrdertDao")
public class UserSpecialOrdertDaoImpl implements IUserSpecialOrdertDao{

	private Logger log = Logger.getLogger(this.getClass());
	
	@Resource(name = "SQLBaseDao")
	private ISQLBaseDao sqlBaseDao;
	
	@Resource(name = "baseDaoX")
	private IBaseDaoX baseDaoX;
	
	/**
	 * 
	 * @Title: getUserSpecialOrderT 
	 * @Description:  根据订单Id获取订单信息
	 * @param oid 订单Id
	 * @author YHQ 
	 * @since V2.5.7
	 * @return UserspecialorderT    返回类型
	 * 
	 */
	@Override
	@Transactional(readOnly = true)
	public UserspecialorderT getUserSpecialOrderT(String oid) {
		
		try {
			// 根据订单Id获取订单信息
			return sqlBaseDao.sqlToCustomBeanUnique(UserspecialorderT.class, UserSpecialOrdertSQL.GET_USER_SPECIAL_ORDERT_BY_ID, oid);
		} catch (Exception e) {
			log.error("根据订单Id获取临时订单信息时出现异常   类：" + this.getClass() + " getUserSpecialOrderT()");
		}
		
		return null;
	}

	/**
	 * 
	 * @Title: updateSpecialOrderById 
	 * @Description: 修改订单临时变数据 
	 * @param userspecialorderT 要修改的订单信息
	 * @author YHQ 
	 * @since V2.5.7
	 * @return Boolean    返回类型
	 * 
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public Boolean updateSpecialOrderById(UserspecialorderT userspecialorderT) {
		
		try {
			baseDaoX.update(userspecialorderT);
			return true;
		} catch (Exception e) {
			log.error("修改订单临时变数据时出现异常   类：" + this.getClass() + " updateSpecialOrderById()", e);
		}
		
		return false;
	}

}
